<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Module: files</title>

<!--
    <script src="http://shjs.sourceforge.net/sh_main.min.js"> </script>
    <script src="http://shjs.sourceforge.net/lang/sh_javascript.min.js"> </script>
-->
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/node-dark.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">
    
    <h1 class="page-title">Module: files</h1>
    
    



<section>
    
<header>
    <h2>
    files
    </h2>
    
</header>  

<article>
    <div class="container-overview">
    
    
    
        
            <div class="description"><p>The <code>fwlib/files</code> module includes utility functions for working with
files.  Where the methods accept a path parameter, you can pass in either
a path string or an array of strings that make up the path.  The array will
be combined into a single string with a single / between each part of the
path.  This means you don't have to worry about whether the substrings
end or begin with a / when building up a path.  For example:</p>

<pre><code>files.readJSON([fw.appJsCommandsDir, "settings.json"]);
</code></pre>

<p>This call works even though <code>fw.appJsCommandsDir</code> doesn't end in a /.</p></div>
        
        
        
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 5</li></ul></dd>
	
    
    
	
	
	
	
</dl>

        
        
    
    </div>
    
    
    
    
    
    
        <h3 class="subsection-title">Requires</h3>
        
        <ul>
            <li>module:dojo/json</li>
        </ul>
    
    
    
    
    
    
    
    
    
        <h3 class="subsection-title">Methods</h3>
        
        <dl>
            
<dt>
    <h4 class="name" id="append"><span class="type-signature">&lt;static> </span>append</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Appends a string to the end of a text file.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFilePath</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The path to the file to read.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inText</code></td>
            
            
            <td class="type">
            
                        String
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The string to append to the file.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 204</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>True if the text could be appended, false otherwise.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">Boolean</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="convertURLToOSPath"><span class="type-signature">&lt;static> </span>convertURLToOSPath</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns a path that's appropriate for the local OS.  Most Fireworks
path arguments are URLs that begin with <code>file://</code>, which can't be
used in the OS X or Windows shells.  For instance,
<code>"file:///C|/Program%20Files/Adobe"</code> would be returned as
<code>"C:\Program Files\Adobe"</code>.  Escaped characters in the URL are
unescaped in the returned path.  By default, the path is also
wrapped in quotes, so that spaces in the path don't trip up the
command line shell.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		<th>Default</th>
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inURL</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                </td>
            
            
            <td class="description last"><p>The file URL to convert.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inDontQuote</code></td>
            
            
            <td class="type">
            
                        Boolean
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    false
                
                </td>
            
            
            <td class="description last"><p>Pass true to prevent the
returned path from being quoted.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 595</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The OS appropriate version of the file URL.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">String</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="copyDirectoryContents"><span class="type-signature">&lt;static> </span>copyDirectoryContents</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Copies all the files from one directory to directory.  The source
directory will be copied recursively.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFromPath</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The path to the source directory.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inToPath</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The path to the destination directory.
If this directory doesn't exist, it will be created, but only if
the last directory in the path doesn't exist.  If directories
further up the path don't exist, then the call will fail.  For
example, if <code>file://path/to/a</code> exists, then passing
<code>file://path/to/a/folder</code> will create the <code>folder</code> directory.
But if only <code>file://path/to</code> exists, the call will fail.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 407</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="createTempDirectory"><span class="type-signature">&lt;static> </span>createTempDirectory</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns the path to a newly created directory in the local system's
temp folder.</p>
    </div>
    
    
    
    
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 521</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The path to the new temp directory or null if
there was a problem creating the directory.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">String</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="getCreatedDate"><span class="type-signature">&lt;static> </span>getCreatedDate</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns a <code>Date</code> object containing the date and time the file was
created.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFilePath</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The path to the file.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 315</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The creation date of the file, or <code>null</code> if the
file doesn't exist.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">Date</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="getCurrentScriptDirectory"><span class="type-signature">&lt;static> </span>getCurrentScriptDirectory</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns the path to the directory that contains the script that
called the function.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFunction</code></td>
            
            
            <td class="type">
            
                        Function
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>A function that is guaranteed to throw
an exception.  The simplest is <code>function(){0()}</code>.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 489</li></ul></dd>
	
    
    
	
	
	<dt class="tag-see">See:</dt>
	<dd class="tag-see">
        <ul>
            <li>getCurrentScriptURL</li>
        </ul>
	</dd>
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The path to the directory containing script that
defined <code>inFunction</code>.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">String</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="getCurrentScriptFilename"><span class="type-signature">&lt;static> </span>getCurrentScriptFilename</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns the name of the script that called the function.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFunction</code></td>
            
            
            <td class="type">
            
                        Function
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>A function that is guaranteed to throw
an exception.  The simplest is <code>function(){0()}</code>.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 506</li></ul></dd>
	
    
    
	
	
	<dt class="tag-see">See:</dt>
	<dd class="tag-see">
        <ul>
            <li>getCurrentScriptURL</li>
        </ul>
	</dd>
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The filename of the script that defined <code>inFunction</code>.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">String</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="getCurrentScriptURL"><span class="type-signature">&lt;static> </span>getCurrentScriptURL</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns the <code>file://</code> URL to the script file that called the
function.  In complicated scripts, it's often useful to load other
scripts that are located in the same directory or nearby directories.
Normally, you can access the current script's path via
<code>fw.currentScriptDir</code>, but that value becomes null after one script
calls another via <code>fw.runScript()</code>.</p>

<p>The <code>getCurrentScriptURL()</code> function works around this by exploiting
the fact that JS exceptions in Fireworks have a <code>fileName</code> property
that points to the script that was executing when the exception
occurred.  So you can pass in a function that is guaranteed to throw
an exception when it is called.  <code>getCurrentScriptURL()</code> will call
the function, catch the exception, and then return the path to your
script.  Hackery!</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFunction</code></td>
            
            
            <td class="type">
            
                        Function
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>A function that is guaranteed to throw
an exception.  The simplest is <code>function(){0()}</code>.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 458</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The path to the script that defined <code>inFunction</code>.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">String</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="getModifiedDate"><span class="type-signature">&lt;static> </span>getModifiedDate</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns a <code>Date</code> object containing the date and time the file was
last modified.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFilePath</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The path to the file.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 331</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The last modified date of the file, or <code>null</code> if the
file doesn't exist.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">Date</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="getSize"><span class="type-signature">&lt;static> </span>getSize</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns the size of the file in bytes.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		<th>Default</th>
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inPath</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                </td>
            
            
            <td class="description last"><p>The path to the file.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inUnit</code></td>
            
            
            <td class="type">
            
                        String
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    ""
                
                </td>
            
            
            <td class="description last"><p>An optional unit in which to report
the file size.  This parameter can be <code>"B"</code>, <code>"KB"</code>, <code>"GB"</code>, or
<code>"TB"</code>.  The size will be returned with the thousands separated by
commas and the unit value added to the end, e.g. <code>"12,420 KB"</code>.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 351</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The size of the file in bytes, or <code>-1</code> if the
file doesn't exist.  If a value is passed in <code>inUnit</code>, the size
is returned as a string.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">Number</span> |
		
		<span class="param-type">String</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="path"><span class="type-signature">&lt;static> </span>path</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns a path that is made up of the arguments to the function.
There is guaranteed to be only one slash between each argument, so
so calling <code>files.path("foo/bar", "My Command.jsf")</code> will return
<code>"foo/bar/My Command.jsf"</code>.  This avoids having to constantly check
whether a directory path you have stored in a variable has a
trailing / or not.</p>

<p>You can also pass in a single array of strings that will be combined
in the same way.  This is mostly used by the other functions in this
module, which can take either a string or an array of strings for
their path arguments.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>arguments</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>Two or more strings to combine into
a path, or a single array of strings.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 551</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>A path created from the combination of the arguments.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">String</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="read"><span class="type-signature">&lt;static> </span>read</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns the contents of a text file.  If the file does not exist,
an empty string is returned.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFilePath</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The path to the file to read.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 79</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The text contents of the file.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">String</span> |
		
		<span class="param-type">Array</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="readChunks"><span class="type-signature">&lt;static> </span>readChunks</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Reads the contents of a text file one chunk at a time, passing each
            chunk to the <code>inCallback</code> parameter.  If the file does not exist,
            the callback will never be called.</p>

<pre><code>        The file reading is done synchronously, but breaking the reads up
        into chunks may sometimes be more efficient for very long files.
        You can also return `false` from the callback to stop reading the
        file part way through.
</code></pre>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFilePath</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The path to the file to read.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inChunkSize</code></td>
            
            
            <td class="type">
            
                        Number=8192
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The number of bytes to read per
                chunk.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inCallback</code></td>
            
            
            <td class="type">
            
                        Function
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>A function that will be called after
                each chunk is read from the file.  The function is called with
                two parameters: a string containing the most recent chunk and
                a number indicating the position of the beginning of the current
                chunk within the file.  Return <code>false</code> from the callback to stop
                reading the file.  Note that the last chunk in the file may be
                less than <code>inChunkSize</code> bytes long.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 130</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="readJSON"><span class="type-signature">&lt;static> </span>readJSON</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns the contents of a JSON file as a JS object.  An object
passed in via the <code>inDefaultData</code> param will have its properties
overridden by the data from the JSON file.  If the file does not
exist, inDefaultData is returned unmodified.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		<th>Default</th>
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFilePath</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                </td>
            
            
            <td class="description last"><p>The path to the file to read.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inDefaultData</code></td>
            
            
            <td class="type">
            
                        Object
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    null
                
                </td>
            
            
            <td class="description last"><p>An object holding default
properties that will be overriden by the JSON data.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 242</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The JSON object from the file.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">Object</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="write"><span class="type-signature">&lt;static> </span>write</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Writes a string to a text file.  It will overwrite a file that
already exists at the path.  The text is always written out in
UTF-8 format, rather than ISO-8859-1, so that accented characters
are reproduced correctly.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		<th>Default</th>
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFilePath</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                </td>
            
            
            <td class="description last"><p>The path to the file to write to.
The full path to the new file must already exist, or the call
will fail.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inText</code></td>
            
            
            <td class="type">
            
                        String
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                </td>
            
            
            <td class="description last"><p>The string to write to the file.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inIncludeBOM</code></td>
            
            
            <td class="type">
            
                        Boolean
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    false
                
                </td>
            
            
            <td class="description last"><p>Pass true to create the file with
a UTF-8 byte order mark at the beginning of the file.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 177</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="writeJSON"><span class="type-signature">&lt;static> </span>writeJSON</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Writes a JS object to a JSON text file.  The JSON is pretty-printed
by default.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		<th>Default</th>
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inFilePath</code></td>
            
            
            <td class="type">
            
                        String
                         | 
                    
                        Array
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                </td>
            
            
            <td class="description last"><p>The path to the file to write to.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inData</code></td>
            
            
            <td class="type">
            
                        Object
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                </td>
            
            
            <td class="description last"><p>The object to convert to JSON.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inSpacer</code></td>
            
            
            <td class="type">
            
                        String
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    "\t"
                
                </td>
            
            
            <td class="description last"><p>An optional string that is used to
indent the JSON output.  The default value is "\t".  Because the
Fireworks <code>file.readline()</code> method returns null if a line is
longer than 2047 characters, you will generally want to use a
spacer string to force the JSON output to include only one
property per line.  This makes the file slightly larger but it
also makes it more likely that the JSON can be read back in by
Fireworks successfully.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/files.js, line 291</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    
    
</dd>

        </dl>
    
    
    
    
    
</article>

</section>  




</div>

<nav>
    <h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-DomStorage.html">DomStorage</a></li><li><a href="module-files.html">files</a></li><li><a href="module-fonts.html">fonts</a></li><li><a href="module-layers.html">layers</a></li><li><a href="module-prefs.html">prefs</a></li><li><a href="module-underscore.html">underscore</a></li></ul><h3>Classes</h3><ul><li><a href="a321565296.html">DomStorage</a></li><li><a href="module-layers.Layer.html">Layer</a></li><li><a href="module-layers.LayerTree.html">LayerTree</a></li><li><a href="module-prefs.PrefsStorage.html">PrefsStorage</a></li><li><a href="_.html">_</a></li></ul>
</nav>

<br clear="both">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3</a> on Mon Jul 08 2013 09:13:10 GMT-0700 (PDT)
</footer>

<script> sh_highlightDocument(); </script>
</body>
</html>
